﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace LitTools
{
    public partial class GMManager
    {
        //展示命令GUI
        private bool showCommondGUI = false;
        //GUI上的指令
        private string commondStrOnGUI = string.Empty;
        //输入框风格
        private GUIStyle textFieldStyle;
        //提交按钮风格
        private GUIStyle subBtnStyle;

        private void Update()
        {
            if (Input.GetKeyUp(KeyCode.BackQuote))
                showCommondGUI = !showCommondGUI;
        }

        private void OnGUI()
        {
            if (!showCommondGUI) return;
            //输入框
            textFieldStyle = GUI.skin.textField;
            textFieldStyle.fontSize = 30;
            textFieldStyle.alignment = TextAnchor.MiddleLeft;
            GUILayout.BeginHorizontal("Box");
            commondStrOnGUI = GUILayout.TextField(commondStrOnGUI,
                textFieldStyle,
                GUILayout.Height(50), GUILayout.Width(300));
            //提交按钮
            subBtnStyle = GUI.skin.GetStyle("button");
            subBtnStyle.fontSize = 30;
            if (GUILayout.Button("Submit",
                subBtnStyle,
                GUILayout.Height(50), GUILayout.Width(100)))
            {
                if (!string.IsNullOrEmpty(commondStrOnGUI))
                    Call(commondStrOnGUI);
                else
                    Debug.LogError("commond can not be null");
            }
            //清理按钮
            if (GUILayout.Button("Clear",
                subBtnStyle,
                GUILayout.Height(50), GUILayout.Width(100)))
            {
                if (!string.IsNullOrEmpty(commondStrOnGUI))
                    commondStrOnGUI = "";
            }
            GUILayout.EndHorizontal();
        }
    }
}